if (!window.V3)
	window.V3 = {};



/**
 * 案件相关
 */
V3.Icase = {
		
	openCase : function(sceneId, titleName,width,height,image16, optName, sceneName, viewLayoutName){
		var params = {
			image16 : image16,
			displayName : titleName,
			width : width,
			height : height,
			configSceneId : sceneId,
			optName : optName
		};
		SinoPortal.View.createTab(sceneName, viewLayoutName,sceneId,params);
	}
}
/**************************************************
 * 添加、编辑组织机构信息 【龙文友(2011-06-12)】
 **************************************************/
function btnAction(sceneId, titleName,width,height,image16, optName, sceneName, viewLayoutName) {
	var params = {
		image16 : image16,
		displayName : titleName,
		width : width,
		height : height,
		configSceneId : sceneId,
		optName : optName
	};
	SinoPortal.View.createWin(sceneName, viewLayoutName,sceneId,params);
}
function openWinByUUId(sceneId, titleName,width,height,image16, optName, sceneName, viewLayoutName,uuid){
	var params = {
			image16 : image16,
			displayName : titleName,
			width : width,
			height : height,
			configSceneId : sceneId,
			optName : optName,
			uuid:uuid
		};
		SinoPortal.View.createWin(sceneName, viewLayoutName,sceneId,params);
}
function writAction(sceneId, titleName,width,height,image16, optName, sceneName, viewLayoutName,taskId,processInstanceId){
	var params = {
			image16 : image16,
			displayName : titleName,
			width : width,
			height : height,
			configSceneId : sceneId,
			optName : optName,
			taskId:taskId,
			processInstanceId:processInstanceId
		};
		SinoPortal.View.createWin(sceneName, viewLayoutName,sceneId,params);
}


function onValidatePwd(sceneId){
	var password = document.getElementById(sceneId+'_form:'+sceneId+'_fieldset'+'password').value;
	var newPassword = document.getElementById(sceneId+'_form:'+sceneId+'_fieldset'+'newPassword').value;
	var rePassword = document.getElementById(sceneId+'_form:'+sceneId+'_fieldset'+'rePassword').value;
	if(password != undefined && newPasswords != undefined && rePassword != undefined ){
		if(password.length<0){
			alert('请输入旧密码！');
			return false;
		}else if(newPassword < 0){
			alert('请输入新密码！');
			return false;
		}else if(newPassword != rePassword){
			alert('输入的密码错误，确认密码输入错误！');
			return false;
		}else{
			return true;
		}
	}else{
		alert('输入错误！');
		return false;
	}	
}
 
/**
 * 新建接警信息
 * @return
 */
function openAddAccept(viewBeanId){
	var sceneId = "duty-case-scene";
	var layoutId ="add-duty-case-accept";
	var viewBeanId = viewBeanId;
	var params = {
	    displayName:"新建接警信息",		
	    image16 : "icons/cog_add.png",
		width:500,
		height:500
	};
	SinoPortal.View.createWin(sceneId,layoutId,viewBeanId,params);		
}



V3.Writ= {
	delWrit : function(compId){ 
		var sel = SinoPortal.PageView.dataView.getSelected(compId+"_right_main_ul");
		if(sel.length==0){
			SinoPortal.Confirm.show("error",null,"请先选择一个文书。");
			return;
		}
		var  img = sel[0].children[0].src;
		if(img.indexOf("leaf.png")==-1) {
				SinoPortal.Confirm.show("error",null,"请先选择一个文书。");
			  return;
		}
		var id = sel[0].id;
		var params = id.split(",");
		
		SinoPortal.Confirm.showConfirm('确认','您确定要删除文书['+params[3]+']？',compId+'_deleteSelectedNode("'+compId+','+params[2]+'")');
	},
	delWritDir : function(compId){ 
		var sel = SinoPortal.PageView.dataView.getSelected(compId+"_right_main_ul");
		if(sel.length==0){
			SinoPortal.Confirm.show("error",null,"请先选择一个目录。");
			return;
		}
		var  img = sel[0].children[0].src;
		if(img.indexOf("node.png")==-1) {
				SinoPortal.Confirm.show("error",null,"请先选择一个目录。");
			  return;
		}
		var id = sel[0].id;
		var params = id.split(",");
		
		SinoPortal.Confirm.showConfirm('确认','您确定要删除目录['+params[3]+']？',compId+'_delWritDir("'+compId+','+params[2]+'")');
	}, 
	saveWritCheck : function(compId,id){ 		
		var writname = document.getElementById(compId+'_form:'+id);
		if(writname == undefined ||writname.value.length==0){
			SinoPortal.Confirm.show("error",null,"请先输入文书名称。");
			return;
		}
		var c =	V3.Writ.checkValue(writname.value,'文书名称');
		if(c) eval(compId+'_saveWrit()');
	},
	editWritNode : function(compId){ 
		var sel = SinoPortal.PageView.dataView.getSelected(compId+"_right_main_ul");
		if(sel.length==0){
			SinoPortal.Confirm.show("error",null,"请先选择一个文书。");
			return;
		}
		var  img = sel[0].children[0].src;
		if(img.indexOf("leaf.png")==-1) {
				SinoPortal.Confirm.show("error",null,"请先选择一个文书。");
			  return;
		}
		var id = sel[0].id;
		var params = id.split(",");
		SinoPortal.View.createWin('writ-scene','writ-edit-layout',compId,{type:'update',displayName:'修改文书',selectId:params[2]})		 
		 
	},
	editWritDir : function(compId){ 
		var sel = SinoPortal.PageView.dataView.getSelected(compId+"_right_main_ul");		
		if(sel.length==0){
			SinoPortal.Confirm.show("error",null,"请先选择一个目录。");
			return;
		}
		var  img = sel[0].children[0].src;
		if(img.indexOf("node.png")==-1) {
				SinoPortal.Confirm.show("error",null,"请先选择一个目录。");
			  return;
		}
		var id = sel[0].id;
		var params = id.split(",");
		SinoPortal.View.createWin('writ-scene','writ-edit-dir',compId,{type:'updatedir',displayName:'修改目录',selectDir:params[2]});
		 
	},
	saveWritDirCheck : function(compId,id){  
		var writSubDirName = document.getElementById(compId+'_form:'+id); 
		if(writSubDirName == undefined ||writSubDirName.value.length==0){
			SinoPortal.Confirm.show("error",null,"请先输入目录名称。");
			return;
		} 	 
    var c =	V3.Writ.checkValue(writSubDirName.value,'目录名称');
    if(c) eval(compId+'_saveWritDir()');
	} ,
	checkValue:function(v,title){ 
		var s = new Array("\/","\\","\<","\>","\:","'","\"","*","?","\|",".");
		for(var i=0;i<s.length;i++){
			if(v.indexOf(s[i]) != -1){
				alert(title+'包含无效字符'+s[i]);
				return false;
			}
		}
		return true;
	}
}

